package ZhuJie.ZhuJie3;

import java.lang.reflect.Method;

public class PersonTest {
    public static void main(String[] args) throws NoSuchMethodException {
        Class<Person> personClass = Person.class;
        //判断反射注解类对象是否存在

        //类的
        if (Person.class.isAnnotationPresent(Description.class)) {
            Description annotation = personClass.getAnnotation(Description.class);
            String value = annotation.value();
            System.out.println("value = " + value);
        }

        //方法的
        Method speak = personClass.getMethod("speak");
        if (speak.isAnnotationPresent(Description.class)){
            Description annotation = speak.getAnnotation(Description.class);
            String value = annotation.value();
            System.out.println("value = " + value);
        }

    }
}
